package ubc.cs.cpsc210.sustainabilityapp.model;

import java.util.Comparator;

public class ComparePOIsByDistance implements Comparator<PointOfInterest> {
    
    private LatLong start;
    
    public ComparePOIsByDistance(LatLong start) {
        this.start = start;
    }
    
    public ComparePOIsByDistance(PointOfInterest start) {
        this.start = start.getLatLong();
    }    
    
    public int compare(PointOfInterest poi1, PointOfInterest poi2) {
        double d1 = start.distanceTo(poi1.getLatLong());
        double d2 = start.distanceTo(poi2.getLatLong());
        return Double.compare(d1, d2);
    }

}
